package org.example;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 请求转发跳转
 * request.getRequestDispotcher(url).foward(request,response)
 * 可以让服务器跳转到客户端
 * 服务端行为
 */
@WebServlet("/s03") //路径
public class Servlet03 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 接收客户端请求的参数
        String uname = request.getParameter("uname");
        System.out.println("servlet03 name：" + uname);

        // 请求转发跳转到servlet04
        //request.getRequestDispatcher("s04").forward(request,response);

        // 请求转发跳转到html页面
        request.getRequestDispatcher("login.html").forward(request, response);
    }
}

